package com.zhz.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ：zhz
 * @date ：Created in 2021/02/07
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description: 路由模式|Routing模式   交换机类型：direct  ==>需要交换机
 **/
@Configuration
public class DirectConfig {
    //声明队列
    @Bean
    public Queue directQ1(){
        return new Queue("direct_sb_mq_q1");
    }
    @Bean
    public Queue directQ2(){
        return new Queue("direct_sb_mq_q2");
    }
    //声明交换机exchange
    @Bean
    public DirectExchange setDirectExchange(){
        return new DirectExchange("directExchange");
    }
    //绑定交换机和队列
    @Bean
    public Binding bindDirectBinding1(){
        return BindingBuilder.bind(directQ1()).to(setDirectExchange()).with("china.changsha");
    }
    @Bean
    public Binding bindDirectBinding2(){
        return BindingBuilder.bind(directQ2()).to(setDirectExchange()).with("china.beijing");
    }
}
